﻿namespace OneWorks.Utils.AdoNet
{
    using Configuration;

    public class DbProviderFactory
    {
        static readonly DbProviderSection Section;

        static DbProviderFactory()
        {
            Section = System.Configuration.ConfigurationManager.GetSection("DbProvider") as DbProviderSection;
        }

        public static IDbUtility GetDbUtility(string key)
        {
            if (Section == null) return null;

            DbProviderElement element = Section.Providers[key];

            return new DbUtility(element.Value, element.Type);
        }
    }
}
